package com.skywaregroup.arenal;

import javax.persistence.*;
import javax.xml.bind.annotation.*;

@XmlRootElement(name="Speciality") 
@XmlAccessorType(XmlAccessType.NONE) 
@Entity
@Table(name="specialities")
public class Speciality {
	
	@Id 
    @Column(name="code")
	public Integer code;
	
	@XmlElement(name="Code")
	public String getCode() {
		return String.format("%02d", this.code);
	}
	
	public void setCode(String s){
		if (!s.matches("^\\d{2}$")) {throw new IllegalArgumentException("Code must be 2-digits string.");}
		this.code = Integer.parseInt(s);
	}
	
	@XmlElement(name="Name") 
	@Column(name="name") 
	public String name;

}
